﻿using System;
using System.Linq;
using System.ServiceProcess;

namespace RemoteWorker.Server
{
    internal class Program
    {
        private const string RunInConsoleArgumentName = "-console";
        private const string RunInConsoleArgumentShortName = "-c";

        private static void Main(string[] args)
        {
            RemoteWorkerServerService remoteWorkerServerService = new RemoteWorkerServerService();

            if (args != null && args.Any(a => a == RunInConsoleArgumentName || a == RunInConsoleArgumentShortName))
            {
                remoteWorkerServerService.Start(args);
                Console.WriteLine("Press any key to exit");
                Console.ReadKey();
                remoteWorkerServerService.ConsoleStop();
            }
            else
                ServiceBase.Run(remoteWorkerServerService);
        }
    }
}